import express from 'express';
import { registerUser, loginUser, getUserProfile } from '../controllers/userController';
import { protect } from '../middleware/authMiddleware';

const router = express.Router();

// 当有 POST 请求发送到 /register 时，调用 registerUser 函数
router.post('/register', registerUser);
router.post('/login', loginUser);

// 当请求这个路由时，会先经过 protect 中间件，再到达 getUserProfile
router.get('/profile', protect, getUserProfile);

export default router;